#  *_* coding:utf8 *_*
import tkinter
import tkinter.font as myFont

import time

result_text = ""
ALL_MESSAGE = ""
SEND_MESSAGE = ""
dram_result_lab = ""
FRIEND_USER = "微风通信"
MYSELF = "我"

def show_msg(msg, send_flag=True):
    global ALL_MESSAGE, SEND_MESSAGE, result_text, dram_result_lab
    dram_result_lab["text"] = "friend: " + FRIEND_USER
    person = FRIEND_USER
    if send_flag:
        SEND_MESSAGE = msg
        person = MYSELF
    ALL_MESSAGE += (person + "\t" + time.ctime() + "\n" + msg + "\n\n")
    result_text.delete(0.0, tkinter.END)
    result_text.insert("end", ALL_MESSAGE)

def window_show():
    global result_text, dram_result_lab
    root = tkinter.Tk()
    root.title("微风")
    root.geometry("700x600+800+100")

    entry_font1 = myFont.Font(size=17, family="楷体")
    entry_font2 = myFont.Font(size=12, family="华文中宋")

    dram_result_lab = tkinter.Label(root, text="微风通信", justify="center", font=entry_font2, bg="DarkOrange")
    dram_result_lab.place(x=10, y=20)

    result_text = tkinter.Text(root, width=53, height=20, font=entry_font2, bg="SkyBlue")
    result_text.place(x=10, y=50)

    input_entry = tkinter.Entry(root, highlightcolor='Goldenrod', highlightthickness=1, font=entry_font1,
                                bg="Lavender")
    input_entry.place(x=10, y=470, width=540, height=50)

    input_button = tkinter.Button(root, text="发送", justify="center",  font=entry_font2, bg="Wheat", width=9,
                                  command=lambda: show_msg(input_entry.get()))
    input_button.place(x=450, y=550)

    root.mainloop()

if __name__ == '__main__':
    window_show()

